package com.my.mail2.loadblanch;

import com.my.mail2.service.IEmailService;
import org.springframework.stereotype.Component;

/**
 * 轮询负载均衡
 */
@Component
public class RoundRobinLoadBalance extends RandomLoadBalance {

    /**
     * 索引
     */
    private volatile byte index = 0;

    @Override
    public IEmailService select() {
        int size = this.emailServiceList.size();
        return this.emailServiceList.get(index++ % size);
    }
}
